package com.rd.student.ruanjian.class1.duhang.Week04.New01;

public class Test07 extends Thread{
    public static void main(String[] args) {
        Test07 test07 = new Test07();
        new Thread(test07::ai).start();
        new Thread(test07::ac).start();
    }

    public synchronized void ai(){
        int[] ai = {1,2,3,4,5,6,7};
        for (int i = 0; i < ai.length; i++) {
            System.out.print(ai[i]);
            notify();
            try {
                wait();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }

    public synchronized void ac(){
        String[] ac = {"A","B","C","D","E","F","G"};
        for (int i = 0; i < ac.length; i++) {
            System.out.print(ac[i]);
            notify();
            try {
                wait();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}

